/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.mavlink;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class Attitude implements MessagePayload {
	public int time_boot_ms;
	public float roll;
	public float pitch;
	public float yaw;
	public float rollspeed;
	public float pitchspeed;
	public float yawspeed;
	
	
	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.putInt(time_boot_ms);
		bb.putFloat(roll);
		bb.putFloat(pitch);
		bb.putFloat(yaw);
		bb.putFloat(rollspeed);
		bb.putFloat(pitchspeed);
		bb.putFloat(yawspeed);
		return Arrays.copyOf(bb.array(), bb.position());
	}
	
	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		time_boot_ms = bb.getInt();
		roll = bb.getFloat();
		pitch = bb.getFloat();
		yaw = bb.getFloat();
		rollspeed = bb.getFloat();
		pitchspeed = bb.getFloat();
		yawspeed = bb.getFloat();
	}
}
